home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / applic / NCSA_Telnet / PC / msdos / misc / dev_note.txt < prev    next >
Encoding:
Text File  |  1993-05-07  |  46.8 KB  |  1,184 lines

  1.  
  2.  
  3. NCSA Telnet
  4. Developers Guide
  5.  
  6. This is an ASCII-printable version of the developers' documentation.
  7.  
  8.  
  9. Version 2.3 release
  10. National Center for Supercomputing Applications
  11. The code and documentation are in the public domain.
  12.  
  13.  
  14. Note to developers:
  15.  
  16. Thanks for your interest and support of this source code.  Please give us your 
  17. comments on where the libraries and/or source need more documentation.
  18.  
  19. We keep a running list of bugs and modify the source code ourselves,  so 
  20. please submit diffs for the changes you make to avoid duplicated effort.  
  21.  
  22. For questions, send us email first, think about it for a while, read the 
  23. developers documentation again, then give us a call.
  24.  
  25. Chris Wilson
  26. cwilson@ncsa.uiuc.edu
  27.  
  28. Ryan Grant
  29. rgrant@ncsa.uiuc.edu
  30.  
  31. Compiler Notes
  32.  
  33. This version was compiled with Microsoft C version 7.0.  The Macro Assembler
  34. code was assembled using MASM 5.1, although it also assembles with MASM 6.0.
  35. does.
  36.  
  37.  
  38. ----------------------
  39. TCP Kernel Calls
  40.  
  41. Tim Krauskopf                        July 11, 1988
  42.  
  43. netsetip(ipnum)
  44. char ipnum[4];        IP address to use.
  45. Set my IP address.  This routine must be called before 
  46. calling netinit, in order for netinit to know what return 
  47. address to use during initialization.  Usually called by a 
  48. session layer routine.
  49.  
  50. netconfig(hw)
  51. char *hw;        Hardware type - string of <10 chars.
  52. This call tells the kernel what type of hardware to use, 
  53. "AppleTalk" or "Ether" on the Mac, for example.  When 
  54. multiple hardware types are supported, the lower layer must 
  55. be informed of which type to use.  Called by Snetinit() 
  56. after the value is read from the configuration file.
  57.  
  58. netparms(irq,address,ioaddr)
  59. int irq;          Hardware parameter,  irq is the interrupt request level
  60. int address;      Shared memory segment address to use for starting
  61.                   Ethernet driver
  62. int ioaddr;       Hardware I/O address parameter
  63.    Set hardware dependent network configuration.  The address
  64. and I/O address parameters only apply if the hardware needs 
  65. them.  These values are filled in by the Session layer in 
  66. most cases.
  67.  
  68. neteventinit()
  69. Initializes network event queue so that errors and 
  70. connection information can be posted.  VERY IMPORTANT.  
  71. Called by Snetinit().
  72.  
  73. netarptime(secs)
  74. int secs;         Amount of time in seconds to try to find local hosts or
  75.                   local gateways.
  76. A particularly slow machine may take five seconds to respond 
  77. to an ARP request.  Most return an answer within 1/2 second.   
  78. This timeout produces the "local host not responding" error.
  79.  
  80. netsetmask(mask)
  81. char mask[4];        Subnet mask to use for future gateway calculations
  82. Set the subnetting mask.  If this is not called before 
  83. netinit(),  netinit() will install the default addressing 
  84. mask for the class A,B or C network according to the address 
  85. in netsetip.
  86.  
  87. netgetmask(mask)
  88. char mask[4];        location to put the copy of the subnet mask
  89. Copies the subnetting mask.  Not very useful if called 
  90. before the network initialization.  Session layer routines 
  91. are typically used to set the value before you try to call 
  92. netgetmask().
  93.  
  94. netgetip(ipnum)
  95. char ipnum[4];        Location to place IP address
  96. Get my IP address.  Used when one session layer routine sets 
  97. the IP address but another one needs to know the value.  Any 
  98. time after netsetip, netgetip can obtain a copy of the 
  99. address.
  100.  
  101. char *neterrstring(errno)
  102. int errno;        error number of look up
  103. Get a pointer to the error string associated with "errno".  
  104. Your custom error handler can use this to look up a "canned" 
  105. error message.  Copy the message, print it, whatever.  Don't 
  106. worry if the errno is -1, that is a special case that works 
  107. OK.  Neterrstring will always return a valid string.
  108.  
  109. netinit()
  110. Sets up the hardware and initializes vars.  Must be called 
  111. before netopen.  Use of Snetinit() is recommended instead of 
  112. netinit().  It calls Sreadhosts(), netinit() and Ssetgates() 
  113. for you.
  114.  
  115. netsetgate(ipnum)
  116. char ipnum[4];        IP address of gateway
  117. Install this IP number as a gateway.  Does an ARP request 
  118. immediately, because we assume we will need its Ethernet 
  119. address.
  120.  
  121. dl = netdlayer(ipnum)
  122. char *dl;        48-bit Ethernet address or psuedo-address from ARP cache
  123. char  ipnum[4];        IP number to look up with ARP.
  124. Queries the network with a broadcast ARP request every 
  125. second and returns the Ethernet address for the requested IP 
  126. address.  Returns NULL on failure.  Blocks for arptime 
  127. seconds or until the response arrives.  One of the very few 
  128. blocking calls, only done this way because it is easier and 
  129. ARP is so quick.
  130.  
  131. netgetrarp()
  132. Pulls the local Ethernet address stored during the netinit() 
  133. and sends a RARP packet every second.  Waits for the 
  134. response and returns 0 for success or negative for failure.  
  135. If a valid response comes in, then netgetip() will return 
  136. the new IP number.  Unfortunately, to get everything to 
  137. work, the combination netgetip(); netsetip() must be 
  138. executed to set all of the internal variables.
  139.  
  140. netsegsize(size)
  141. int size;        new segment size to use for future connection attempts
  142. Set the maximum segment size (for incoming packets).  This 
  143. value will take affect on all future opening connections, 
  144. whether from netopen() or netlisten().  Can be changed any 
  145. time, but cannot affect current connections, only future 
  146. ones.  Netlisten takes this value when called, not when the 
  147. connection eventually opens.
  148.  
  149. netquench(limit)
  150. int limit;        largest TCP window that can be advertised.  
  151. Set the maximum window (for incoming packets) that future 
  152. connections should allow.   Will have no effect when set to 
  153. a value over the program's maximum.
  154.  
  155. netfromport(port)
  156. int port;        TCP protocol number to use for next netopen request.
  157. When netopen starts a connection, the destination port 
  158. number is requested by the application, i.e. 23 for the 
  159. well-known telnet port.  The return (local) port number is 
  160. usually randomly generated to be unique from all local ports 
  161. in use.  If the application needs a specific local port 
  162. number (as the default port for FTP data transfers 
  163. requires), this call can force a particular number.  The 
  164. setting goes away after the next netopen call.
  165.  
  166. pn = netopen(ipnum,service)
  167. char ipnum[4];        Address of machine to connect to, in binary
  168. int service;        TCP port to attempt to connect to, often the WKA for a 
  169. service
  170. int pn;            port number for use in later calls to just about every 
  171. routine available
  172. Open a connection to another machine (up to 30 times).  
  173. Returns a file descriptor to use in later calls.  Netopen is 
  174. often used only in a session layer routine which does name 
  175. to IP address translation before calling netopen.  See 
  176. Snetopen() for open which includes name translation.
  177.  
  178. cnt = netread(pn,buf,len)
  179. int pn;            port number from netopen()
  180. char *buf;        pointer to data space to read into
  181. int len;            maximum length of data to read
  182. int cnt;            returns # of bytes read, -1 on closed connection, 0 
  183. for waiting
  184. Similar to UNIX read, but using a file descriptor from 
  185. netopen().  Does not block EVER.
  186.  
  187. cnt = netwrite(pn,buf,len)
  188. int pn;            port number from netopen()
  189. char *buf;        pointer to data space to write from
  190. int len;            length of data to try to write
  191. int cnt;            returns # of bytes written, -1 on closed connection, 0 
  192. for waiting
  193.  
  194. Similar to UNIX write, but using a file descriptor from 
  195. netopen().  Does not block EVER.
  196.  
  197. netclose(pn)    
  198. int pn;            port number from netopen()
  199. Close a connection, like closing a file.  You must make sure 
  200. (with netpush()) that all data which went through netwrite() 
  201. to this file descriptor has been sent before closing.  
  202. Before closing, you will also want to read all of the 
  203. available data from the connection if you don't want to lose 
  204. it.
  205.  
  206. netshut()
  207. Shut down communication, disable interrupts.  It is not wise 
  208. to call any network routines at all after calling netshut().
  209.  
  210. netsleep(secs)
  211. int secs;        number of seconds to wait before returning
  212. This is what keeps the network drivers alive.  It makes sure 
  213. that any required ACKs are sent.  Often called with a 
  214. parameter of zero, but can be made to wait some # of secs.  
  215. Has a resolution of 1/18th of a second on PC, 1/60th on Mac.
  216.  
  217. netest(pn)
  218. int pn;            port number from netopen()
  219. Returns 0 if the connection is in established mode, <0 if 
  220. one side or the other has closed the connection.
  221.  
  222. cnt = netpush(pn)
  223. int pn;            port number from netopen()
  224. int cnt;            number of bytes still waiting to be delivered 
  225. (outgoing)
  226. Sets push bit on transmit, returns size of output queue 
  227. (unacknowledged data).  Check to see that this value is zero 
  228. before calling netclose().  Unless you don't care.
  229.  
  230. netqlen(pn)
  231. int pn;            portnumber from netopen()
  232. Returns the number of bytes waiting to be read (incoming) 
  233. which have been acked, but have not been taken from the 
  234. queue.
  235.  
  236. netroom(pn)
  237. int pn;            port number from netopen()
  238. Get information on buffer space from a port.  netroom 
  239. returns the number of bytes available for a netwrite() 
  240. command to write into.  If the TCP is caught up, this will 
  241. be WINDOWSIZE, if we are loaded, this could be zero.
  242.  
  243. netgetftp(a,pn)
  244. int a[8];        return values
  245. int pn;            port number from netopen()
  246. Get information about an active connection.  Returns the IP 
  247. address of the other machine which is connected to you and 
  248. the incoming and outgoing  TCP port numbers in use.  a[0] to 
  249. a[3] is the IP number of the other host.  Note that these 
  250. are integers, not characters!  a[4]  and a[5] are the high 
  251. and low bytes (yet stored in integers) of your local port 
  252. number.  a[6] and a[7] are the high and low bytes of the 
  253. other side's port number for this connection. 
  254.  
  255. pn = netlisten(service)
  256. int service;        TCP port number to listen to.
  257. int pn;            Returns a port number equivalent to a netopen() port 
  258. number
  259. Listen to a TCP port number.  The TCP will establish the 
  260. connection for you automatically.   You will be notified 
  261. with an event when the connection occurs.  Try not to get 
  262. the TCP port number confused with the netopen() port number.  
  263. The TCP port number defines the network connection between 
  264. machines while the netopen() port number is a local 
  265. descriptor for a given connection.
  266.  
  267. netusend(ipnum,port,retport,buf,len)
  268. char *ipnum[4];    IP number of other machine
  269. int port,retport;        to and from ports for the other machine's UDP socket
  270. char *buf;        data to be sent in the packet
  271. int len;            number of bytes of data to send, must fit in 512 byte 
  272. packet
  273. Send a UDP packet to another machine, to a certain port, 
  274. with the data in buf, length n.
  275.  
  276. netulisten(port)
  277. int port;        port to be sensitive about
  278. Listen for a UDP packet on a certain incoming port.  Often 
  279. port is the same as retport on a netusend().  Any packets 
  280. for this port will be kept for reading later.  Another 
  281. packet for this port before a neturead will overwrite the 
  282. last one.  This should be expanded later to give similar 
  283. socket addressing as TCP uses.
  284.  
  285. theevent = netgetevent(class,theclass,dat)
  286. int class;        Classes to search for (OR combination)
  287. int *theclass;        Actual class of the event returned (return value)
  288. int *dat;        Data which tags the event
  289. int theevent;        Which event has occurred
  290. Receive the next event in the queue.  Classes are in 
  291. whatami.h.  Not usually called by the user because the user 
  292. will want the session layer handling of Sgetevent().  
  293. Returns 0 on no event available.
  294.  
  295. netputevent(class,event,dat)
  296. int class;        Class of the event to post
  297. int event;        Which event within that class to post
  298. int dat;            The data to carry in the event queue
  299. Place an event into the event queue to be picked up later.  
  300. The user may want to define classes to be posted this way.   
  301. See Sgetevent().
  302.  
  303. netputuev(class,event,dat)
  304. int class;        Class of the event to post
  305. int event;        Which event within that class to post
  306. int dat;            The data to carry in the event queue
  307. Place an event into the event queue.  First checks to see if 
  308. there already is an identical such event.  If so, another 
  309. copy will not be posted.
  310.  
  311. netposterr(enum)
  312. int enum;        Error number in errorclass.
  313. Post a user error message.  The error message is one from 
  314. the list in TOOLS.C.  This message will wait in the queue 
  315. until an ERRORCLASS event is requested.
  316.  
  317. cnt = neturead(buf)
  318. char *buf;        data area to drop the UDP packet (<512 bytes)
  319. int cnt;            actual length of the packet which is ready
  320. Reads the data from a UDP packet which was received.  
  321. Returns the number of bytes read into buf, or -1 if there is 
  322. no packet available to read.  Automatically clears the 
  323. incoming UDP buffer for the next read.
  324.  
  325. Session Layer routines
  326.  
  327. hostform.h
  328. Include file which contains the structure of the machine 
  329. information record and the configuration information record.  
  330. Use these structures with the following calls to read or 
  331. manipulate machine specific information.  Includes struct 
  332. machinfo and struct config.
  333. whatami.h
  334. Currently contains the definition of PC vs. Mac in terms of 
  335. program and compiler settings to get the code to compile on 
  336. both the Mac and PC.  Also includes netevent.h.
  337. netevent.h
  338. Contains the list of event types, both low-level event types 
  339. used internally, and the events which the application 
  340. program will pay attention to.   See documentation section 
  341. on rules for event handling that explain what you can do 
  342. with events.
  343.  
  344.  
  345. Sgetconfig(conp)
  346. struct config *conp;    Pointer to a config structure which will receive a 
  347. copy of current data
  348. Copies the config structure to user memory.  The hosts file 
  349. contains a lot of configuration information that the 
  350. application may need to know.  The structure of the data 
  351. area is in hostform.h.  
  352.  
  353. mp = Shostlook(name)
  354. char *name;        name of machine to get information about
  355. struct machinfo *mp;    Pointer to machine information record
  356. Takes a machine name (standard ASCII string) and returns a 
  357. pointer to the machine information record associated with 
  358. that name.  Searches the sname field first, then the hname 
  359. field.  Returns NULL if not found.  The structure definition 
  360. is in hostform.h.  Take care when writing to fields in this 
  361. structure (i.e. don't).  If you mess up the data, strange 
  362. things may happen.  Shostlook does  a simple lookup on the 
  363. name field, so the "default" record can be looked up if 
  364. necessary.
  365.  
  366. mp = Sgethost(name)
  367. char *name;        name or IP number of machine to get information about
  368. struct machinfo *mp;    Pointer to machine information record
  369. Takes a machine name or IP number in ASCII format 
  370. (192.17.20.10) or a special shorthand form (#10) and returns 
  371. a pointer to the machine information record associated with 
  372. that name.   Uses Shostlook() to look up name if number is 
  373. not used.  Returns NULL if not found.  The structure 
  374. definition is in hostform.h.  Sgethost guarantees that the 
  375. record returned has a valid IP number which Snetopen() will 
  376. accept.  Sgethost should be the primary lookup call to 
  377. determine whether the domain name server is required or not.  
  378. If the IP number is given, a pointer to the "default" 
  379. machine is returned with a temporary IP number installed.  
  380. "default" cannot be returned as a real machine because 
  381. Sgethost guarantees a real IP number in the machine record.
  382.  
  383. mp = Slooknum(mnum)
  384. int mnum;        Machine number to look for
  385. struct machinfo *mp;    Pointer to machine information record
  386. Used primarily for domain lookups, this number is unique for 
  387. all entries in the memory host list.
  388.  
  389. mp = Slookip(ipnum)
  390. char *ipnum;        IP number of the host to look for
  391. struct machinfo *mp;    Pointer to machine information record
  392. Look up host information when you know the host's IP number.  
  393. Used by background ftp server.
  394.  
  395. mp = Smadd(name)
  396. char *name;        ASCII name of the host to add to the memory host list
  397. struct machinfo *mp;    Pointer to machine information record
  398. Adds a machine to the host list, generating a unique host 
  399. number for it.  Copies the configuration information from 
  400. "default".  Returns a pointer to the machine record created.  
  401. Returns NULL if no memory could be allocated.  Be careful 
  402. updating the information in the machine record.  If the name 
  403. already exists somewhere as a session or host name, it just 
  404. returns that record pointer.
  405.  
  406. Shostfile(newname)
  407. char *newname;    pointer to new configuration file name
  408. Takes a pointer to static storage of the host file name.   
  409. The storage associated with the name must remain allocated.  
  410. Default is "config.tel".  Typically called with an argv[] 
  411. parm.
  412.  
  413. Snetinit()
  414. Calls Sreadhosts(), netinit(), neteventinit(), and 
  415. Ssetgates() for you and initializes the timer queue.    
  416. Returns non-zero on error.  Sreadhosts() sets up the config 
  417. structure, so Sgetconfig() can be called after Snetinit().  
  418. RARP handling is done in Snetinit() - if RARP fails, 
  419. Snetinit returns -2 -- this condition requires a netshut() 
  420. to clear any interrupt drivers.  A -1 return means that the 
  421. netinit() never succeeded so the interrupt drivers were 
  422. never installed.
  423.  
  424. Sreadhosts()
  425. Reads the hosts file, using the filename provided by 
  426. nethostfile().  Uses the new type of config file.  Sets 
  427. Smachlist to NULL before reading the file and creating the 
  428. list.  Processes and logs all information to the config 
  429. structure or into the machinfo list.  Calls some of the 
  430. setup options for ftp, rcp, screen modes, etc.  Called by 
  431. Snetinit, user does not need to call this routine. 
  432.  
  433. Ssetgates()
  434. This routine is called by Snetinit() automatically.  It sets 
  435. the netmask with the field read from the hosts file, turns 
  436. on ftp and rcp if they are specified in the hosts file, and 
  437. traverses the machinfo list to set up any gateways which are 
  438. marked.
  439.  
  440. pn = Snetopen(mp,tport)
  441. struct machinfo *mp;    Machine information record obtained from Sgethost()
  442. int tport;        TCP port to attempt connection with
  443. int pn;            Port number passed through from netopen()
  444. Tries to connect to the specified port on that machine and 
  445. returns the port descriptor for netread and netwrite.  
  446. Should be used instead of netopen().  Calls netopen() and 
  447. uses any special configuration information found in the 
  448. machinfo record.  Sets a timer for the connection timeout 
  449. which will be posted in an event.  You cannot access this 
  450. connection until you are notified with an event that shows 
  451. the connection opened or failed.
  452.  
  453. Sdomain(name)
  454. char *name;        name of the machine to look up, s/b in DOMAIN format
  455. Tries to use the DOMAIN name server to look up the IP number 
  456. of the named host.   Sdomain() posts appropriate events to 
  457. notify you of the results.  If the name does not have any 
  458. periods, the default suffix from the config structure is 
  459. added to the lookup.  All domain events return a machine 
  460. number which can be looked up with Slooknum() to find out 
  461. which machine is referred to.   Remember, the local host 
  462. file lookup is faster, so look up the machine name with 
  463. Sgethost() first.  Returns 0 on success, -1 if there is no 
  464. name server to query.
  465.  
  466. Snewns()
  467. Rotate name servers.  If there is more than one nameserver 
  468. in the machine list, the one with the next highest number 
  469. will become the current nameserver.  Wraps to nameserver 1 
  470. when there are no more nameservers.
  471.  
  472. Ssetns(ipn)
  473. char ipn[4];        IP number of nameserver to become primary nameserver.
  474. For situations when your primary nameserver is not indicated 
  475. in the config file, but is obtained over the network 
  476. somehow, this sets that host up as nameserver #1.  The ns #1 
  477. set by Snewns() will rotate to ns #2 as necessary.
  478.  
  479. Stask()
  480. Should be called instead of netsleep() to support the timer 
  481. queue and network updates.   Sgetevent() calls Stask() for 
  482. you.  The FTP server can't function without repeated Stask() 
  483. calls.
  484.  
  485. Stimerset(class,event,dat,howlong)
  486. int class;        Class of event which should be posted
  487. int event;        Event number which should be posted
  488. int dat;            Associated data which should be posted
  489. int howlong;        Seconds to wait before posting this event
  490. Stimerset() adds events to the timer queue.  Stask() 
  491. contains the checks to post any events which have come due. 
  492.  
  493. Stimerunset(class,event,dat)
  494. int class;        Class of event which should be dequeued
  495. int event;        Event number which should be dequeued
  496. int dat;            Associated data which should be dequeued
  497. Searches the timer queue for a matching entry and removes 
  498. the entry from the queue without generating an event.  The 
  499. timer may have just gone off with the event in the event 
  500. queue.  This procedure will not prevent that event from 
  501. occurring, only those which have unexpired timers are 
  502. removed.
  503.  
  504. theevent = Sgetevent(class,theclass,dat)
  505. int class;        Classes to search for (OR combination)
  506. int *theclass;        Actual class of the event returned (return value)
  507. int *dat;        Data which tags the event
  508. int theevent;        Which event has occurred
  509. Sgetevent() does the background processing of ftp, rcp and 
  510. domain name lookup.  Events are posted with netputevent() 
  511. and are usually posted by lower layer routines.  Calling 
  512. Snetopen() will guarantee that you will get either a CONOPEN 
  513. or CONFAIL event depending on how things went.  The 
  514. associated data for CONXXXX events is always the port number 
  515. of the connection involved.  The routine will return 0 if 
  516. there are no events available.  Class types are in whatami.h 
  517. and the user may define new events and classes as described 
  518. under "events".  
  519. Currently, it is quite common to receive undesired extra 
  520. events which are for ports which you don't have defined.  
  521. Check the data tag for validity.
  522.  
  523. FILE *Sopencap()
  524. Opens the capture file with the previously stored name.  
  525. Returns a file pointer or NULL if there is an error.  Use 
  526. Snewcap() to change the name.  Always opens for append.
  527. Snewcap(name)
  528. char *name;        Name to use for a capture file
  529. Copies the name into private storage for use by Sopencap().  
  530. Limit of 80 chars on name length (no warning).
  531.  
  532. Stekmode(m)
  533. Sftpmode(m)
  534. Srcpmode(m)
  535. Scwritemode(m)    
  536. int m;            Value of boolean flag to set
  537. Sets modes and turns switches for the session layer.  Tek is 
  538. tektronix mode.  FTP and rcp turn the listeners on and off.  
  539. When writemode is 1 (true), direct writes to the screen 
  540. should be enabled.  Tek and writemode are simply services to 
  541. the upper layers, they only store the boolean flag.
  542.  
  543. Stmode()
  544. Sfmode()
  545. Srmode()
  546. Scmode()    
  547. Returns the value of the boolean flag set above.  
  548.  
  549. Snewpsfile(s)
  550. Snewhpfile(s)
  551. Snewtekfile(s)
  552. char *s            new file name to use
  553. For each of the graphic options, Postscript, tek and HPGL, 
  554. the configuration structure maintains a filename as a 
  555. service to higher layers.  These routines change those 
  556. filenames.  Pointers to the filenames are obtained through 
  557. the structure copy which is retrieved from Sgetconfig().
  558.  
  559. Scheckpass(user,passwd)
  560. char *user;        User name to check the password of
  561. char *passwd;        The password to check the validity of
  562. Returns true if the passwd associated with the user field 
  563. matches the value in the password file associated with 
  564. telnet.  If there is a password file and the username is not 
  565. present, returns false.  If no password file is specified in 
  566. the hosts file, returns true.
  567.  
  568. Sneedpass()
  569. Returns a boolean flag indicating whether we need to check 
  570. FTP passwords.  The determination is made depending upon 
  571. whether there has been a filename specified with the 
  572. passfile option in the config file.
  573.  
  574. Scompass(password,encrypt)
  575. char *password;    The password to compare
  576. char *encrypt;        The encryption to check against
  577. Checks to see if the encrypted string has been encrypted 
  578. from a particular password string.   Returns true or false.
  579.  
  580. Sftpname(s)
  581. char *s;        Space to copy the name of the file being transferred
  582. The name of the current file being transferred by FTP is 
  583. stored internally.  Use Sftpname() to get a copy of that 
  584. internal name.
  585.  
  586. Sftphost(host)
  587. char *host;        Space to copy the name of the host involved.
  588. The IP number of the FTP client for FTP transfers is stored 
  589. internally.  Use Sftphost() to get a copy of that internal 
  590. number.  Then you can look up the host's name with 
  591. Slookip().
  592.  
  593. Sftpuser(user)
  594. char *user;        Space to copy the username.
  595. The name field from the FTP USER command is stored 
  596. internally.  Use Sftpuser() to get a copy of that name.
  597.  
  598. Sftpstat(bytes)
  599. long *bytes;        Pointer to long, number of bytes
  600. The value copied into this long int returns number of bytes 
  601. transferred or left to transfer in the currently active ftp 
  602. transfer.  Used to update status displays.
  603.  
  604.  
  605.  
  606. Events -- how to use them
  607.  
  608. The routines netgetevent() (at a low level) and 
  609. Sgetevent()(at the session level) look for events which are 
  610. stored in NCSA Telnet's event queue.  Sgetevent() calls 
  611. netgetevent(), so if you are using the session layer 
  612. library, you will never call netgetevent().  Sgetevent() 
  613. sifts through the events and captures events related to the 
  614. background name serving and ftp file transfers.  All other 
  615. events are passed through to the application.
  616. Classes
  617. Events are divided into classes to help different portions 
  618. of the application look for only certain kinds of events.   
  619. When you call one of the getevent routines, the class which 
  620. you pass to the routine is a mask of the OR combination of 
  621. the classes that you want to retrieve from the event queue.  
  622. When the routine returns with a greater than zero event 
  623. number, that mask will have been transformed into the exact 
  624. class to which the returned event belongs.  The classes are 
  625. defined below.
  626. Events
  627. For each class, several events are defined.  They are 
  628. documented individually, along with the use of the data 
  629. value which is returned from the getevent call.
  630. User-defined events
  631. Applications programmers are welcome to use class 0x80 (128) 
  632. for their own events.  Events in each of the predefined 
  633. classes in the range 128-255 are also available for use.  
  634. Specifically, use events 128-255 of the USERCLASS because 
  635. they will be more convenient to use.  Use of any events or 
  636. classes not in these ranges may conflict with future NCSA 
  637. software.  If you want certain events to be defined by NCSA, 
  638. let us know.  The official "defined events" list will be 
  639. updated periodically.
  640. Timer events
  641. Stimerset() and Stimerunset() control a separate queue from 
  642. the event queue.  The important thing to know is that when a 
  643. timer goes off, it places its specific event into the event 
  644. queue.  You may use user-defined event types to set timers 
  645. for yourself in this queue.  Some events like DOMFAIL and 
  646. CONFAIL are caused by timers if something doesn't occur to 
  647. unset the timers for those events.
  648. minitel.c
  649. Look at minitel.c for the simplest possible telnet.  This 
  650. one doesn't even have a telnet command parser and it only 
  651. talks to BSD hosts.  It does show you how to handle events 
  652. for the simple cases.
  653.  
  654. The following events are defined in netevent.h:
  655.  
  656.  
  657. #define USERCLASS    1
  658. #define ICMPCLASS    2
  659. #define ERRCLASS        4
  660. #define SCLASS    8
  661. #define CONCLASS    0x10
  662.  
  663. #define ERR1        1    /* an error message is waiting, ERRCLASS */
  664.  
  665. #define IREDIR    1    /* ICMP redirect, ICMPCLASS */
  666.  
  667. #define CONOPEN     1    /* connection has opened, CONCLASS */
  668. #define CONDATA     2      /* there is data available on this connection */
  669. #define CONCLOSE     3    /* the other side has closed its side of the connection */
  670. #define CONFAIL     4    /* connection open attempt has failed */
  671.  
  672. #define UDPDATA     1    /* UDP data has arrived on listening port, USERCLASS */
  673. #define DOMOK        2    /* domain name ready */
  674. #define DOMFAIL     3    /* domain name lookup failed */
  675. #define FTPCOPEN     20     /* FTP command connection has opened */
  676. #define FTPCLOSE     21     /* FTP command connection has closed */
  677. #define FTPBEGIN    22     /* FTP transfer beginning, dat =1 for get, 0 for put */
  678. #define FTPEND       23     /* FTP transfer ending */
  679. #define FTPLIST     24     /* FTP file listing taking place */
  680. #define FTPUSER      25     /* FTP user name has been entered */
  681. #define FTPPWOK     26     /* FTP password verified */
  682. #define FTPPWNO     27     /* FTP password failed */
  683. #define RCPBEGIN     30    /* RCP beginning */
  684. #define RCPEND     31    /* RCP ending */
  685.  
  686. #define UDPTO     1    /* UDP request from DOMAIN timed out, SCLASS */
  687. #define FTPACT    2    /* FTP transfer is active, keep sending */
  688. #define TCPTO      3    /* TCP for DOMAIN timed out */
  689. #define RCPACT     4    /* rcp is active, needs CPU time */
  690. #define RETRYCON     5    /* retry connection packet, might be lost */
  691.  
  692.  
  693.  
  694. Class USERCLASS
  695. Event UDPDATA
  696. To get this event you must have already called netulisten 
  697. with a port number.  A UDP packet with some data has arrived 
  698. for you on that port.  The data field for the event is the 
  699. UDP port number which you were listening to.  In the future, 
  700. you will be able to listen to multiple ports and the data 
  701. field will become important.  Port 998 is arbitrarily used 
  702. by our domain name server.
  703. Event DOMOK
  704. To get this event, you must have already placed a domain 
  705. name request.  You may get more than one DOMOK for one 
  706. request.  The data field contains the machine number of the 
  707. name you looked up.  You can look up the machine record with 
  708. Slooknum() now.  The IP number has been placed into the 
  709. record.  A Snetopen() with that machine record should 
  710. succeed now.
  711. Event DOMFAIL
  712. To get this event, you must have already placed a domain 
  713. name request.  You may get more than one DOMFAIL for one 
  714. request.  The data field contains the machine number of the 
  715. name you looked up.  That machine name could not be 
  716. resolved.   You may also have an error event waiting for you 
  717. which explains why the resolve failed.
  718. Event FTPCOPEN
  719. A command connection has been established to your background 
  720. FTP server.  NCSA Telnet uses this to post informative 
  721. messages.
  722. Event FTPCLOSE
  723. The command connection for your server FTP has closed.
  724. Event FTPBEGIN
  725. A file transfer to or from your machine has begun.  The data 
  726. field=1 for get (transfer from) and 0 for put (transfer to) 
  727. transfers.
  728. Event FTPEND
  729. A file transfer or a LIST command has ended.
  730. Event FTPLIST
  731. A LIST command has begun for your background FTP.
  732. Event FTPUSER    
  733. A USER command has been entered for the background FTP.
  734. Event FTPPWOK
  735. An FTP PASS command has been entered and verified by 
  736. comparing to the entries in the password file.
  737. Event FTPPWNO
  738. An FTP PASS command has been entered and rejected by failing 
  739. to match anything in the password file.
  740. Event RCPBEGIN
  741. Someone has started an rcp transfer to or from your 
  742. computer.
  743. Event RCPEND
  744. That rcp has ended.
  745. Class ICMPCLASS
  746. Event IREDIR
  747. The netsleep() routine automatically does a netgetevent() 
  748. for ICMP redirect messages and performs the addressing 
  749. change required by the ICMP redirect.  When an ICMP redirect 
  750. packet is received, this event is posted by the ICMP 
  751. routine.  Bugfix in 2.2 makes sure ALL redirects are 
  752. registered.
  753. Class ERRCLASS
  754. Event ERR1
  755. There is currently only one error event which pertains to 
  756. all of the possible errors.  These events should be 
  757. reclassified as ERRWARNING, ERRINFO, ERRFATAL, etc., so the 
  758. rest of this class is reserved.  The data field contains the 
  759. error number which can be looked up with neterrstring().
  760. Class SCLASS (session class)
  761. The entire SCLASS is for special session layer events.  You 
  762. will not receive these events from Sgetevent() because they 
  763. are always removed.
  764. Event UDPTO
  765. The current UDP domain request timed out.
  766. Event FTPACT
  767. When FTP is active, it uses as much CPU as it can get.  To 
  768. get more CPU it posts events back to itself.
  769. Event TCPTO
  770. not used, we don't need TCP lookups.
  771. Event RCPACT
  772. rcp posts this event back to itself when it needs CPU.
  773. Event RETRYCON
  774. Snetopen() posts this in a timer to send multiple SYN 
  775. packets if the first one is lost.
  776. Class CONCLASS
  777. Event CONOPEN
  778. A connection has just opened.  This may be a connection 
  779. which you are listening to, or one which you are trying to 
  780. open with Snetopen().  Remember Snetopen() does not block 
  781. until the connection is open.  The data field returns the 
  782. port number (descriptor) of the connection.
  783. Event CONDATA
  784. Data has arrived for a certain port number.  The data field 
  785. contains that port number.  Because this event always comes 
  786. up when there is data in the incoming TCP buffer, you never 
  787. have to poll netread() to find out if there is data to be 
  788. read.  If you get CONDATA events, there is data to be read, 
  789. if you are not getting CONDATA events, then there won't be 
  790. data to be read.  Unless you drop an event, of course.  
  791. CONDATA events which arrive after a CONCLOSE event or a 
  792. netclose() call may get a -1 return from netread(), 
  793. indicating that the connection has no more data or does not 
  794. exist.
  795. Event CONCLOSE
  796. If the host you are talking to decides to drop the 
  797. connection, or reset it, then you may get a CONCLOSE event.  
  798. This can be interpreted as the last CONDATA event that you 
  799. will get.  There may be a large amount of data waiting for 
  800. you to pick it up with netread() even after receiving a 
  801. CONCLOSE event.  The correct procedure is to take data from 
  802. netread() until you receive a 0 or -1 return code and then 
  803. call netclose() to finalize your side of the connection.
  804. Event CONFAIL
  805. The timer ran out on a connection which you tried to open.  
  806. This does not mean that you are done.  You must netclose() 
  807. to allow the memory for that port to be re-used.
  808.  
  809.  
  810. Virtual Screen Kernel Calls
  811.  
  812. Gaige B. Paulsen                            October 31, 1987
  813.                                     updated July 14, 
  814. 1988
  815.  
  816. int VSinit(max)
  817. int max;        Maximum number of Virtual screens to allow.
  818. Initializes the Virtual Screen Kernel for use with up to max 
  819. screens. 
  820. Returns 0 if successful.
  821.  
  822. VSscrn *VSwhereis(i)
  823. int i;            Virtual Screen to examine.
  824. Returns the current address of the virtual screen control 
  825. record.  This is used for debugging.
  826.  
  827. int VSnewscreen( maxlines, screensave, maxwid, IDC)
  828. int maxwid;        How wide can this window be.  Only tested for 80 and 132.
  829. int maxlines;        Maximum number of lines to save.
  830. int screensave;    Is scrollback enabled at start?
  831. int IDC;        Do we have support for insert and delete of characters.
  832.  
  833. Creates a new screen if possible.   VSnewscreen returns a 
  834. number >=0 if it succeeds, which is to be used as the window 
  835. parameter(w) in all subsequent calls to vs routines.  If the 
  836. return value is <0, there was an error, and no screen was 
  837. created.
  838.  
  839. VSdestroy(w)
  840. int w;            Window number to destroy.
  841. Destroy the window corresponding to w.  Returns an error if 
  842. applicable.
  843.  
  844. VSdetatch(w)
  845. int w;            Window number to detach.
  846. Detach the window corresponding to w.  Returns an error if 
  847. applicable.  Note that this function currently just calls 
  848. VSdestroy(w).  Previously and hopefully sometime in the 
  849. future as well, it did/will allow for the destruction of a 
  850. screen without freeing memory.
  851.  
  852. VSredraw(w,x1,y1,x2,y2)
  853. int w;            Window number to redraw.
  854. int x1, y1,x2,y2;    Bounds of the rectangle to be drawn, in local window 
  855. coordinates.
  856. Redraw the portion of window w which lies within (x1,y1) - 
  857. (x2,y2).  The coordinates are local to the window and should 
  858. NOT be adjusted for scrollback, as most of scrollback is 
  859. handled by the VS routines and not the RS.
  860.  
  861. VSwrite(w,ptr,len)
  862. int w;            Window number to write to.
  863. int  len;        How many characters to write.
  864. char *ptr;        Where to get the characters.
  865. The big routine.  This one is called to write a character 
  866. stream to the virtual screen w.  VSwrite calls VSem to parse 
  867. the emulation.
  868.  
  869. VSclear(w)
  870. int w;            Window number to clear.
  871. Clear the virtual screen of window w.
  872.  
  873. char VSkbsend(w,k,echo)
  874. int w;            Window number to send the characters from.
  875. int echo;        Boolean - whether to local echo the key.
  876. unsigned char k;    VT-100 key code to send
  877. Sends the VT-102 representation of the key represented by k.  
  878. This routine uses somewhat of a hack by calling RSsendstring  
  879. which is supposed to know how to send characters to 
  880. whichever port corresponds to window w.  The echo flag only 
  881. applies to special keys (like arrows) and will cause them to 
  882. echo on the local screen as they are transmitted.
  883.  
  884. VSclearall(w)
  885. int w;            Window number to clear all of.
  886. This routine currently does nothing.  It was originally 
  887. intended clear the current screen and all of the scrollback 
  888. as well as setting the top of the scrollback to the top of 
  889. the available storage space, but this was deemed 
  890. unnecessary.....at least for now.
  891.  
  892. VSreset(w)
  893. int w;            Window number to reset.
  894. Resets the virtual screen (w) with respect to VT-100 modes.  
  895. Changes the wrap mode to off and clears the screen as well 
  896. as setting all other modes to their ORIGINAL POWER-ON 
  897. defaults as specified by the VT-100 programmers manual.
  898.  
  899. char *VSgetline(w,y)
  900. int w;            Window number to get line from.
  901. int  y;            Line from which to get the pointer
  902. This routine in now out of date and SHOULD NOT BE USED 
  903. unless you really know what you are doing.  It retrives a 
  904. pointer to the data string associated with line (y) of the 
  905. screen (w).  This ONLY works with lines that are on the 
  906. active vt100 screen (lines 0-23).
  907.  
  908. VSsetrgn(w,x1,y1,x2,y2)
  909. int w;            Window number to set the display region for.
  910. int x1,y1,x2,y2;    The vs's bounding rectangle in GLOBAL VS coordinates .
  911. Set the current display region for window w to (x1,y1)-
  912. (x2,y2).  This will perform 
  913. scrollback/scrollforward/scrollleft/scrollright/etc. as 
  914. necessary to make the current screen reflect the values of 
  915. the passed display region.  It restricts you from doing 
  916. anything really stupid (I hope).
  917.  
  918. VSgetrgn(w,x1,y1,x2,y2)
  919. int w;            Window number to scroll forward in.
  920. int *x1,*y1,*x2,*y2;    Where to retrieve the display region into.
  921.  
  922. Get the current value of the display region (as set by 
  923. setrgn and/or modified by the scroll routines as well as 
  924. auto--scroll).  Pass pointers to the integers you would like 
  925. to have the values put into.
  926.  
  927. VSscrolback(w,in)
  928. int w;            Window number to scroll back in.
  929. int in;            Number of lines to scroll back.
  930. Scroll back in lines in window w if possible.  Note that 
  931. this routine will prevent you from scrolling back beyond the 
  932. top of the buffer, so it is safe to call it whenever you get 
  933. a request to scroll back further, even if you don't know if 
  934. there is data left to scroll back into.
  935.  
  936. VSscrolforward(w,n)
  937. int w;            Window number to scroll forward in.
  938. int n;            Number of lines to scroll forward.
  939. Scrolls forward n lines in window w.  See VSscrolback for 
  940. details.
  941.  
  942. VSscrolright(w,n)
  943. int w;            Window number to scroll right in.
  944. int n;            Number of columns to scroll right.
  945. Scrolls right n columns in window w.  See VSscrolback for 
  946. details.
  947.  
  948. VSscrolleft(w,n)
  949. int w;            Window number to scroll forward in.
  950. int n;            Number of columns to scroll left.
  951. Scrolls left n columns in window w.  See VSscrolback for 
  952. details.
  953.  
  954. VSscrolcontrol(w,scrolon,savescroll)
  955. int w;            Window number to set scroll variables for.
  956. int scrolon;        Do we scroll or don't we?
  957. int savescroll;        Save cleared lines into scrollback.
  958. Changes the value of the scrolon variable in window w, 
  959. therefore disabling and enabling scrollback, not really 
  960. necessary.  If savescroll is on, all clearscreen commands 
  961. will load the text into the scrollback buffer.
  962.  
  963. VSsnapshot(w)
  964. int w;            Window number to take snapshot of.
  965. Currently does nothing.  Will/should eventually make a copy 
  966. of the current screen into the scrollback buffer.  This is 
  967. most easily done by sending 24 line feeds and then copying 
  968. the values of lines (-24) - (-1) into 0-24.  But, I hope to 
  969. do this before  2.1 and the source release.
  970.  
  971. int VSmaxwidth(w)
  972. int w;            Window number to retrieve the maximum width of.
  973. Retrieves the current maximum width of window w.  Used 
  974. primarily to get the maximum possible size of a selection 
  975. for copying. NOTE: a 132 column window in 80 column mode 
  976. returns 80.
  977.  
  978. long VSgettext(w, x1, y1, x2, y2, charp, max, EOLS)
  979. int w;            Window number to get text from.
  980. int x1,y1,x2,y2;    The starting and ending points of the text in global VS 
  981. coordinates .
  982. char *charp;        Pointer to the destination of the gotten text.
  983. char  *EOLS;        Pointer to the string to be used for end of line.
  984. long max;        Maximum number of characters charp can hold.
  985. Copies a section of text from window w, which corresponds to 
  986. an area starting from the x1th character of line y1 to the 
  987. x2th character of line y2, inclusive of all of the 
  988. characters on lines y1+1 to y2-1  into a buffer pointed at 
  989. by charp to exceed no more than max and inserting the string 
  990. pointed at by EOLS whenever there is a line transition.  
  991. (...whew...) This is mainly used for copy and print of VS 
  992. data.  Extraneous blanks are ommitted at the end of lines by 
  993. searching backward to the beginning of the line.
  994.             
  995. Global  VS coordinates vs. local coordinates
  996.  
  997. Global
  998. Global coordinates are used to represent a range of 
  999. information that can span the entire VS space as it 
  1000. currently exists.   To accurately portray the area, we must 
  1001. have some standard method of referring to scrollback.  For 
  1002. this, we have chosen to refer to the top of the currently 
  1003. active VT-102 screen as line 0, the bottom of the active 
  1004. screen as line 23, and the lines of scrollback as negative 
  1005. offsets from line 0.  Hence, a line that has been scrolled 
  1006. off by a CR-LF would be seen as line -1.  To perform actions 
  1007. such as scrolling back to the top of the virtual screen, you 
  1008. would ask for lines from (top of buffer) to (top of buffer 
  1009. +length of display window).  Similarly, if you wished to 
  1010. scroll to make the right hand side of a 132 column window 
  1011. visible, you would ask for the columns from (maxwidth -20) 
  1012. to (maxwidth).
  1013. Local 
  1014. Local coordinates are used to represent things that happen 
  1015. relative to the area being displayed by the Virtual Screen.  
  1016. An example would be a portion (or all) of the virtual screen 
  1017. being made visible.  This action would cause whichever lines 
  1018. are in the visible area to be redrawn, therefore you will 
  1019. need to inform the VS routines to do this.  Since the VS 
  1020. routines attempt to maintain as much of the information 
  1021. about scrollback by themselves so as not to burden you with 
  1022. extraneous information, you pass these coordinates as local 
  1023. to the currently active screen.  Therefore, a full redraw 
  1024. would be line 0 character 0 through line 23 character 79, 
  1025. which would then be translated by VSredraw to whatever 
  1026. global coordinates are appropriate.
  1027.  
  1028. Replacing the Terminal Emulation package in the VS 
  1029. routines.
  1030.  
  1031. The VS routines can be used as a basis for just about any 24 line screen 
  1032. terminal emulator.  This document shows how to use the internal routines in 
  1033. vsintern.c to construct a  vsem.c file as a basis for a new terminal emulator.  
  1034.  
  1035. VSem(c,ctr) -
  1036. char *c     pointer to the buffer to use as input to the emulator
  1037. int ctr        how many characters to read from the input buffer
  1038.  
  1039. This is the main emulation routine.  It is the entry point from VSwrite and 
  1040. should be the only thing that needs to be replaced when changing the terminal 
  1041. emulation.
  1042.  
  1043.     escflg: current escape state
  1044.         0 - normal character wait
  1045.         1 - have escape, waiting for next character
  1046.         2 - escape '[' sequence, waiting for parameters
  1047.         3 - escape '#' sequence
  1048.         4 - escape '(' sequence
  1049.         5 - escape ')' sequence
  1050.     c:     pointer to character currently being parsed
  1051.     VSIw: points to the window structure for the current window.
  1052.     VSIwn: is the current window number
  1053.  
  1054. VSI routines from vsintern.c for use in emulation
  1055.  
  1056. VSIreset()            - Cause a terminal reset
  1057. VSItabinit()        - Initialize tabs to default stat (every 8             
  1058.         characters)
  1059. VSItabclear()        - Clear the tab at the current position
  1060.  
  1061. VSIdellines(n,s)        - delete n lines at s (current line if s<0)
  1062. VSIinslines(n,s)        - insert n lines at s (current line if s<0)
  1063.  
  1064. VSIeeol()            - erase to end of line
  1065. VSIebol()            - erase to beginning of line
  1066. VSIel(s)            - erase the entire line s (current line if s<0)
  1067. VSIeeos()            - erase to end of screen
  1068. VSIebos()            - erase to beginning of screen
  1069. VSIes()            - erase the whole screen
  1070.  
  1071. VSIrange()            - check and resolve range errors for x and y
  1072.  
  1073. VSIdraw( VSIwn, x, y, a, len, c)
  1074.                 - draw len characters at (x,y) in attribute a
  1075.                     with the chars at c
  1076. VSIinsstring(len,start)    - insert len characters at the current position         
  1077.             with the chars at start
  1078.  
  1079. VSIdelchars(x)        - delete x characters at the current position
  1080. VSIinschar(x)        - insert x blank characters at the current position
  1081. VSItab()            - move to next tab stop
  1082. VSIsave()            - save current x, y, a
  1083. VSIrestore()            - restore previous x,y,a
  1084.  
  1085. VSIindex()            - index one line
  1086. VSIrindex()            - reverse index one line
  1087.  
  1088. VTsendpos()            - Send the VT-100 cursor report
  1089. VTsendstat()            - Send the VT-100 status report
  1090. VTsendident()        - Send the VT-100 identity report
  1091. VSIsetoption(toggle)    - Set the VT-100 option depending on toggle
  1092.  
  1093.  
  1094.  
  1095. How to write a new PC driver
  1096.  
  1097. There are six routines which must be provided in a new 
  1098. driver.  All of these routines are currently provided in 
  1099. assembly language in one file.   When you write a new 
  1100. driver, you will probably take a current driver and replace 
  1101. each of the six routines in the file.  The current examples 
  1102. are in the ENET subdirectory and the three best examples 
  1103. are:
  1104.  
  1105. NET501.ASM
  1106. 3COM 3C501 driver.  Uses interrupts,  and will be a 
  1107. reasonable template for other interrupt-driven drivers.  I 
  1108. highly discourage trying to improve this driver for the 
  1109. 3C501.  I've tried.
  1110. NETUB.ASM
  1111. Ungermann-Bass (IBM) NIC board driver.  Does not use 
  1112. interrupts.  This driver may be a good template for simple 
  1113. shared-memory boards which divide the memory into pages.
  1114. NET5210.ASM
  1115. MICOM NI5210 driver.  The NI5210 uses the Intel 82586 chip.  
  1116. You will need the Intel databook for this chip in order to 
  1117. understand the driver.  This driver should be directly 
  1118. applicable to all boards which are built around the 82586.  
  1119. Works with 8K or 16K boards.  Only uses 8K of a 16K board, 
  1120. so save your money.
  1121.  
  1122. With dual-ported RAM and intelligent chipsets, interrupts are entirely 
  1123. unnecessary.  The board will automatically buffer a certain number of packets 
  1124. which are picked up when NCSA Telnet has time to process incoming packets.  
  1125. TCP takes care of preventing overruns.
  1126.  
  1127. The six routines are described below.  They generally return -1 on error.  
  1128. getaddr() is usually called first and etopen must be called next for any of 
  1129. the other routines to make sense.  Function pointers for the routines are 
  1130. declared and installed in PCTOOLS.C.  A new driver should install new pointers 
  1131. right alongside the existing ones.
  1132.  
  1133. etopen(eaddr,irq,addr,ioaddr)
  1134. char  eaddr[6];        Hardware ethernet address to use on board.
  1135. int irq;            Interrupt request level from configuration file.
  1136. int addr;        Shared memory base segment address from configuration file.
  1137. int ioaddr;        I/O address from configuration file.
  1138. This routine must do all of the initializations for the 
  1139. Ethernet board.  Any interrupt drivers must be placed, 
  1140. interrupts turned on, base register variables set up, 
  1141. packets initialized and the address set for the board.  Do 
  1142. not return until you are receiving packets.  Most drivers 
  1143. will ignore some of the fields provided.  Map them to 
  1144. whatever values are appropriate for your hardware.
  1145.  
  1146. getaddr(eaddr,addr,ioaddr)
  1147. char eaddr[6];        Buffer to place address.
  1148. int addr;        Base segment address for shared memory
  1149. int ioaddr;        Base I/O address for board
  1150. Some of these parameters are also ignored, depending upon 
  1151. the hardware.  The hardware address from the board's EPROMs 
  1152. should be copied into the eaddr buffer.  This address is 
  1153. generally given back to etopen, so getaddr cannot depend on 
  1154. etopen's initialization.
  1155.  
  1156. etclose()
  1157. Shut down Ethernet board.  Primarily to turn off interrupts.  
  1158. This routine can be just a RET for non-interrupt boards.
  1159.  
  1160. recv()
  1161. Receive a packet.  Used only for boards that do not use 
  1162. interrupts.  The interrupt handler generally replaces the 
  1163. need for recv().  The interrupt handler or recv() must use 
  1164. my undocumented buffering scheme.  Generally, keep the same 
  1165. code and replace the board handling side.
  1166.  
  1167. xmit(packet,size)
  1168. char *packet;        Address of packet to transmit.
  1169. int size;        Size of packet to transmit, including all headers.
  1170. Send out one packet.  This is generally not interrupt 
  1171. driven.  The packet size may be smaller than the minimum 
  1172. Ethernet packet size.  If so, this routine must take care of 
  1173. the details.  The frame to transmit always includes the 
  1174. entire Ethernet frame header, so non-802.3 drivers may need 
  1175. to strip the header to modify higher layer code.
  1176.  
  1177. etupdate()
  1178. Remove one packet from the buffer.  This routine is 
  1179. generally unmodified from driver to driver.  The incoming 
  1180. packet is not copied from the buffer until fully processed, 
  1181. so the driver must wait until etupdate() is called before 
  1182. freeing the space back to the buffer.
  1183.  
  1184.